/*
 * Copyright 2018 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.codegen.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * @author 劳水生
 * @version 1.0.0
 */
public final class CodeUtils {

    private CodeUtils() {
    }

    /**
     * 获取首字母大写的驼峰命名字符串，如： full_name =FullName;
     *
     * @param para
     * @return
     */
    public static String getUpper(String para) {
        if (StringUtils.isNotBlank(para)) {
            StringBuilder sb = new StringBuilder();
            String[] paraArray = para.split("_");

            for (String str : paraArray) {
                if (StringUtils.isNotBlank(str)) {
                    sb.append(str.substring(0, 1).toUpperCase());
                    sb.append(str.substring(1));
                }
            }
            return sb.toString();
        } else {
            return para;
        }
    }

    /**
     * 获取首字母小写的驼峰命名的字符串
     *
     * @param para
     * @return
     */
    public static String getLower(String para) {
        String temp = getUpper(para);
        if (StringUtils.isNotBlank(temp)) {
            return temp.substring(0, 1).toLowerCase() + temp.substring(1);
        }
        return temp;
    }

    /**
     * 转换到行
     *
     * @param param 入参
     * @return
     */
    public static String getLine(String param) {
        if (StringUtils.isNotBlank(param)) {
            return param.replace("_", "-").toLowerCase();
        } else {
            return "";
        }
    }

}
